/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */
#pragma once

#include <Config.h>

#ifdef ANDROID_NDK
#include <ApplicationWindowedAndroid.h>
#endif

#ifdef IPHONE_VERSION
#include <ApplicationWindowedIphone.h>
#else
#ifdef MAC_VERSION
#include <ApplicationWindowedMac.h>
#endif
#endif

#ifdef SAMSUNG_VERSION
#include <ApplicationWindowedAndroid.h>
#endif

#ifdef WIN32
#include <ApplicationWindowedWin.h>
#endif 

#ifdef MARMALADE
#include <ApplicationWindowedMarmalade.h>
#endif 

#include "Creator.h"
#include <lib3d/hard/Hardware.h>
#include <lib3d/node/Root.h>
#include <animate/Animation.h>

namespace liba
{
namespace lib3d
{

class Application :
	public ApplicationWindowed,
	virtual public lib3d::Creator
{
	node::Root * cursor_root;	//must be pointer and destroyed before hardware stop
	node::Camera * cursor_camera;
	node::Node * cursor_node;
	animate::Animation cursor_animation;
	int previous_total_reps_to_load;
	bool show_load_animation;
	int loading_screen_delay;
protected:
	hard::Hardware * hardware;
	virtual void on_loading_start()
	{}
	virtual void on_loading_progress(double progress)
	{}
	virtual void on_loading_finish()
	{}
public:
	bool should_display_load_animation()const
	{
		return show_load_animation;
	}
	bool is_loading_now()const
	{
		return previous_total_reps_to_load != 0;
	}
	void force_display_load_animation()
	{
		this->show_load_animation = true;
	}
	void set_loading_screen_delay(int loading_screen_delay)
	{
		this->loading_screen_delay = loading_screen_delay;
	}

	static node::Camera * load_root(node::Root * root, animate::Animation * animation, const filesystem::String & base_name, const Atom & camera_name );
	const filesystem::String get_cursor()const;
	void change_cursor(const filesystem::String & scene);
	void render_cursor( hard::RenderTarget * rt );

	virtual bool LifeCycle(time_float delta_time) LIBA_OVERRIDE;

	explicit Application(const std::string & caption, const std::string & cmd_line);
	Application(const std::string & caption, int sx, int sy, int resizeable );
	virtual ~Application();

	virtual int window_proc( unsigned msg, unsigned wParam, unsigned lParam );
private:
	filesystem::String cursor_scene;
};

} // namespace lib3d
} // namespace liba
using namespace liba;
